<?php

namespace app\meizhuangapi\controller\gifts;
use app\api\controller\gifts\Gifts as GiftsCon;
use app\api\model\gifts\Gifts as GiftsModel;
use think\Request;
use think\Db;


/**
 * 爆品礼管理控制器
 * Class Gifts
 * @package app\store\controller
 */
class Gifts extends GiftsCon{
    /**
     * 爆品礼详情
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function giftsDetail(){
        $param = Request::instance()->param();
        $model = GiftsModel::apiDetail($param['gifts_id']);
        if(empty($model)){
            return $this->renderError('爆品礼不存在，请刷新后重试');
        }
        $count=Db::name('meizhuang_comment')->where(['wxapp_id'=>$param['wxapp_id']])->count();
        $storeInfo=Db::name('store_shop')->where(['wxapp_id'=>$param['wxapp_id']])->find();
        $tx=Db::name('upload_file')->where(['file_id'=>$storeInfo['logo_image_id']])->find();
        $imgeurl=$tx['file_url'].'/'.$tx['file_name'];
        $storeInfo['imageUrl']=$imgeurl;
        $model['commentCount']=$count;
        $model['gifts_content'] = htmlspecialchars_decode($model['gifts_content']);
        $model['superior_user_id'] = $this->user['user_id'];
        $model['storeInfo']=$storeInfo;
        return $this->renderSuccess($model);
    }
}



